<script lang="ts" setup>
import AccountApi from '~/src/api/AccountApi';

const props = defineProps<{
    modelValue: {
        query: {
            options: { label: any, value: any }[]
        }
    }
}>()
const companyList = ref([])

const form = reactive<Record<any, any>>({})
// onMounted(() => {
//     AccountApi.getCompanyList(props.modelValue.query).then(res => {
//         if (res) {
//             companyList.value = res.data.map(x => ({ label: x.companyName, value: x.companyId }))
//         }
//     })
// })
const rules = {
    companyId: [
        { required: true, message: '请选择公司', trigger: 'blur' }
    ],
}
const formRef = useTemplateRef("formRef")
const confirm = () => {
    formRef.value.validate((validate: boolean) => {
        if (validate) {
            emit('callBack', form.companyId)
        }
    })

}
const cancel = () => {
    emit('callBack')
}
const emit = defineEmits(['callBack'])

</script>

<template>
    <el-form :rules="rules" ref="formRef" :model="form">
        <el-form-item label="公司名称" label-width="80px" prop="companyId">
            <SingleLayerSelect v-model="form.companyId" :options="props.modelValue.query.options" placeholder="请选择公司" />
        </el-form-item>
    </el-form>
    <div style="padding-top: 20px;text-align: right">
        <el-button @click="confirm" type="primary">确认</el-button>
        <el-button @click="cancel">取消</el-button>
    </div>
</template>